3.37 \(\int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx\)

Optimal. Leaf size=101 \[ \frac {(-B+i A) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(-B+i A) \log (\cos (c+d x))}{a d}+\frac {x (A+3 i B)}{2 a} \]

[Out]

1/2*(A+3*I*B)*x/a+(I*A-B)*ln(cos(d*x+c))/a/d-1/2*(A+3*I*B)*tan(d*x+c)/a/d+1/2*(I*A-B)*tan(d*x+c)^2/d/(a+I*a*ta
n(d*x+c))

________________________________________________________________________________________

Rubi [A]  time = 0.12, antiderivative size = 101, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 34, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.088, Rules used = {3595, 3525, 3475} \[ \frac {(-B+i A) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(-B+i A) \log (\cos (c+d x))}{a d}+\frac {x (A+3 i B)}{2 a} \]

Antiderivative was successfully verified.

[In]

Int[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x]),x]

[Out]

((A + (3*I)*B)*x)/(2*a) + ((I*A - B)*Log[Cos[c + d*x]])/(a*d) - ((A + (3*I)*B)*Tan[c + d*x])/(2*a*d) + ((I*A -
 B)*Tan[c + d*x]^2)/(2*d*(a + I*a*Tan[c + d*x]))

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3525

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[(b*d*Tan[e + f*x])/f, x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3595

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> -Simp[((A*b - a*B)*(a + b*Tan[e + f*x])^m*(c + d*Tan[e + f*x])^n)/(2*a*f*
m), x] + Dist[1/(2*a^2*m), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^(n - 1)*Simp[A*(a*c*m + b*d*n
) - B*(b*c*m + a*d*n) - d*(b*B*(m - n) - a*A*(m + n))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A,
B}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0] && GtQ[n, 0]

Rubi steps

\begin {align*} \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx &=\frac {(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac {\int \tan (c+d x) (2 a (i A-B)+a (A+3 i B) \tan (c+d x)) \, dx}{2 a^2}\\ &=\frac {(A+3 i B) x}{2 a}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac {(i A-B) \int \tan (c+d x) \, dx}{a}\\ &=\frac {(A+3 i B) x}{2 a}+\frac {(i A-B) \log (\cos (c+d x))}{a d}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B]  time = 4.98, size = 240, normalized size = 2.38 \[ \frac {(\cos (d x)+i \sin (d x)) (A+B \tan (c+d x)) \left ((B-i A) (\cos (c)-i \sin (c)) \cos (2 d x)+2 d x (A+3 i B) (\cos (c)+i \sin (c))+(A+i B) (-\cos (c)+i \sin (c)) \sin (2 d x)+2 i (A+i B) (\cos (c)+i \sin (c)) \log \left (\cos ^2(c+d x)\right )+4 (A+i B) (\cos (c)+i \sin (c)) \tan ^{-1}(\tan (d x))+4 d x (A+i B) \tan (c) (\sin (c)-i \cos (c))-4 A d x \sec (c)-4 i B d x \sec (c)+4 B (\tan (c)-i) \sin (d x) \sec (c+d x)\right )}{4 d (a+i a \tan (c+d x)) (A \cos (c+d x)+B \sin (c+d x))} \]

Antiderivative was successfully verified.

[In]

Integrate[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x]),x]

[Out]

((Cos[d*x] + I*Sin[d*x])*(-4*A*d*x*Sec[c] - (4*I)*B*d*x*Sec[c] + ((-I)*A + B)*Cos[2*d*x]*(Cos[c] - I*Sin[c]) +
 2*(A + (3*I)*B)*d*x*(Cos[c] + I*Sin[c]) + 4*(A + I*B)*ArcTan[Tan[d*x]]*(Cos[c] + I*Sin[c]) + (2*I)*(A + I*B)*
Log[Cos[c + d*x]^2]*(Cos[c] + I*Sin[c]) + (A + I*B)*(-Cos[c] + I*Sin[c])*Sin[2*d*x] + 4*(A + I*B)*d*x*((-I)*Co
s[c] + Sin[c])*Tan[c] + 4*B*Sec[c + d*x]*Sin[d*x]*(-I + Tan[c]))*(A + B*Tan[c + d*x]))/(4*d*(A*Cos[c + d*x] +
B*Sin[c + d*x])*(a + I*a*Tan[c + d*x]))

________________________________________________________________________________________

fricas [A]  time = 0.74, size = 130, normalized size = 1.29 \[ \frac {2 \, {\left (3 \, A + 5 i \, B\right )} d x e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (2 \, {\left (3 \, A + 5 i \, B\right )} d x - i \, A + 9 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} + {\left ({\left (4 i \, A - 4 \, B\right )} e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (4 i \, A - 4 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - i \, A + B}{4 \, {\left (a d e^{\left (4 i \, d x + 4 i \, c\right )} + a d e^{\left (2 i \, d x + 2 i \, c\right )}\right )}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/4*(2*(3*A + 5*I*B)*d*x*e^(4*I*d*x + 4*I*c) + (2*(3*A + 5*I*B)*d*x - I*A + 9*B)*e^(2*I*d*x + 2*I*c) + ((4*I*A
 - 4*B)*e^(4*I*d*x + 4*I*c) + (4*I*A - 4*B)*e^(2*I*d*x + 2*I*c))*log(e^(2*I*d*x + 2*I*c) + 1) - I*A + B)/(a*d*
e^(4*I*d*x + 4*I*c) + a*d*e^(2*I*d*x + 2*I*c))

________________________________________________________________________________________

giac [A]  time = 0.57, size = 101, normalized size = 1.00 \[ \frac {\frac {{\left (-i \, A - B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{a} - \frac {{\left (3 i \, A - 5 \, B\right )} \log \left (-i \, \tan \left (d x + c\right ) - 1\right )}{a} - \frac {4 i \, B \tan \left (d x + c\right )}{a} - \frac {-3 i \, A \tan \left (d x + c\right ) + 5 \, B \tan \left (d x + c\right ) - A - 3 i \, B}{a {\left (\tan \left (d x + c\right ) - i\right )}}}{4 \, d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="giac")

[Out]

1/4*((-I*A - B)*log(tan(d*x + c) + I)/a - (3*I*A - 5*B)*log(-I*tan(d*x + c) - 1)/a - 4*I*B*tan(d*x + c)/a - (-
3*I*A*tan(d*x + c) + 5*B*tan(d*x + c) - A - 3*I*B)/(a*(tan(d*x + c) - I)))/d

________________________________________________________________________________________

maple [A]  time = 0.17, size = 137, normalized size = 1.36 \[ -\frac {i B \tan \left (d x +c \right )}{d a}-\frac {B \ln \left (\tan \left (d x +c \right )+i\right )}{4 d a}-\frac {i A \ln \left (\tan \left (d x +c \right )+i\right )}{4 d a}-\frac {A}{2 d a \left (\tan \left (d x +c \right )-i\right )}-\frac {i B}{2 d a \left (\tan \left (d x +c \right )-i\right )}-\frac {3 i \ln \left (\tan \left (d x +c \right )-i\right ) A}{4 d a}+\frac {5 \ln \left (\tan \left (d x +c \right )-i\right ) B}{4 d a} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x)

[Out]

-I/d/a*B*tan(d*x+c)-1/4/d/a*B*ln(tan(d*x+c)+I)-1/4*I/d/a*A*ln(tan(d*x+c)+I)-1/2/d/a/(tan(d*x+c)-I)*A-1/2*I/d/a
/(tan(d*x+c)-I)*B-3/4*I/d/a*ln(tan(d*x+c)-I)*A+5/4/d/a*ln(tan(d*x+c)-I)*B

________________________________________________________________________________________

maxima [F(-2)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: RuntimeError} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative e
xponent.

________________________________________________________________________________________

mupad [B]  time = 6.30, size = 95, normalized size = 0.94 \[ -\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )}{4\,a\,d}-\frac {B\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}{a\,d}-\frac {\left (A+B\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{2\,a\,d\,\left (1+\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (-5\,B+A\,3{}\mathrm {i}\right )}{4\,a\,d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((tan(c + d*x)^2*(A + B*tan(c + d*x)))/(a + a*tan(c + d*x)*1i),x)

[Out]

- (log(tan(c + d*x) + 1i)*(A*1i + B))/(4*a*d) - (B*tan(c + d*x)*1i)/(a*d) - ((A + B*1i)*1i)/(2*a*d*(tan(c + d*
x)*1i + 1)) - (log(tan(c + d*x) - 1i)*(A*3i - 5*B))/(4*a*d)

________________________________________________________________________________________

sympy [A]  time = 0.64, size = 160, normalized size = 1.58 \[ - \frac {2 B}{- a d e^{2 i c} e^{2 i d x} - a d} + \begin {cases} - \frac {\left (i A - B\right ) e^{- 2 i c} e^{- 2 i d x}}{4 a d} & \text {for}\: 4 a d e^{2 i c} \neq 0 \\x \left (- \frac {3 A + 5 i B}{2 a} + \frac {i \left (- 3 i A e^{2 i c} + i A + 5 B e^{2 i c} - B\right ) e^{- 2 i c}}{2 a}\right ) & \text {otherwise} \end {cases} - \frac {x \left (- 3 A - 5 i B\right )}{2 a} + \frac {i \left (A + i B\right ) \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{a d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)**2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x)

[Out]

-2*B/(-a*d*exp(2*I*c)*exp(2*I*d*x) - a*d) + Piecewise((-(I*A - B)*exp(-2*I*c)*exp(-2*I*d*x)/(4*a*d), Ne(4*a*d*
exp(2*I*c), 0)), (x*(-(3*A + 5*I*B)/(2*a) + I*(-3*I*A*exp(2*I*c) + I*A + 5*B*exp(2*I*c) - B)*exp(-2*I*c)/(2*a)
), True)) - x*(-3*A - 5*I*B)/(2*a) + I*(A + I*B)*log(exp(2*I*d*x) + exp(-2*I*c))/(a*d)

________________________________________________________________________________________